-
Notifications
You must be signed in to change notification settings - Fork 3k
Added RateLimitedSampler #41925
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added RateLimitedSampler #41925
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds support for a rate-limited sampler alongside the existing fixed-percentage sampler in the Azure Monitor OpenTelemetry SDK. Key changes include:
- Introducing new constants and environment variable handling for RATE_LIMITED_SAMPLER and sampling traces per second.
- Updating
_get_configurations
,_configure
, and SDK constants to select between rate-limited and fixed-percentage samplers. - Implementing
RateLimitedSampler
, utility functions (_get_djb2_sample_score
,_round_down_to_nearest
), and comprehensive tests for sampling behavior.
Reviewed Changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.
Show a summary per file
File | Description |
---|---|
tests/utils/test_configurations.py | Added tests for rate-limited and fixed-percentage sampler env var scenarios |
_constants.py (SDK) | Defined RATE_LIMITED_SAMPLER , FIXED_PERCENTAGE_SAMPLER , and SAMPLING_TRACES_PER_SECOND_ARG |
configurations.py | Enhanced _default_sampling_ratio to branch on sampler type and set appropriate configuration |
_configure.py | Updated setup to instantiate RateLimitedSampler when traces-per-second is set |
exporter/_utils.py | Added _get_djb2_sample_score and improved rounding logic |
_rate_limited_sampling.py | Implemented RateLimitedSamplingPercentage and RateLimitedSampler |
exporter/_constants.py | Defined hash and integer bounds for sampling utilities |
sdk/monitor/azure-monitor-opentelemetry/azure/monitor/opentelemetry/_configure.py
Outdated
Show resolved
Hide resolved
sdk/monitor/azure-monitor-opentelemetry/azure/monitor/opentelemetry/_utils/configurations.py
Show resolved
Hide resolved
sdk/monitor/azure-monitor-opentelemetry/azure/monitor/opentelemetry/_utils/configurations.py
Show resolved
Hide resolved
sdk/monitor/azure-monitor-opentelemetry/azure/monitor/opentelemetry/_utils/configurations.py
Show resolved
Hide resolved
360c7da
to
7183758
Compare
The existing sampler - |
A fresh one created |
Description
Adding support for RateLimitedSampler, inspired by Java Application Insights sampler
https://github.com/microsoft/ApplicationInsights-Java/blob/main/agent/agent-tooling/src/main/java/com/microsoft/applicationinsights/agent/internal/sampling/RateLimitedSamplingPercentage.java
All SDK Contribution checklist:
General Guidelines and Best Practices
Testing Guidelines